package SQLQrys;

public class QrysPartida {
	
	public String insertPartida(){
		return "insert into partida(id,fecha,mercante,pirata,id_ganador,id_mapa) values (?,now(),?,?,?,?)";
	}
	
	public String selectPartida(){
		return "select * from partida where id= ?";
	}
	
	public String selectMaxId(){
		return "select max(id) as maxId from partida";
	}
	
	public String selectPartJug(){
		return "select p.id as id, p.fecha as fecha, jm.nombre as mercante, jp.nombre as pirata, jp.nombre as ganador from partida p, p.id_mapa as mapa"+
					"join jugador jm "+
						"on p.mercante = jm.id "+
					"join jugador jp "+
						"on p.pirata = jp.id "+
					"left join jugador jg "+
						"on p.id_ganador = jg.id "+
					"WHERE (mercante = ? OR pirata = ?) AND id_ganador = 0 "
					+ "order by id";
	}
	
	public String selectIdsPartJug(){
		return "select id from partida where mercante = ? OR pirata = ? AND id_ganador = 0 ";
	}
	
	public String selectParametros(){
		return "select velocidad, alcance, visibilidad from parametros";
	}
	
	public String updateGanador(){
		return "update partida set id_ganador = ? where id = ?";
	}
	
}


